function getUrlParams(){

var locationurl = window.location.href;
var  tem0= locationurl.split("#");

var tem = tem0[0].split('?');
var paramsdata = {};

if (tem.length > 1) {

	var parms = tem[1].split('&');

	for ( var i = 0; i < parms.length; i++) {

		var param = parms[i].split('=');

			paramsdata[param[0]] = param[1];
	}
}

return paramsdata;

}



function valueMapping(value,mapping){
	var res="";
	if(value){
	 res= mapping[value];
	}
	
	 return  res;
	 
}

function fitValue(value){
	
	if(value){
		
	}else{
	value="";
	}
	
	return value;
	
}


var jsTools = {

	/**
	 * 除去最后一个 ,
	 * @param str
	 * @returns
	 */
	removelastComma:function(str){
		
	var last=str.charAt(str.length-1);
	
	if(last==","){
		
		return	str.substring(0,str.length-1);
		
	}else{
		
		return	str;
	}
	
	
	},

	/**
	 * 自动获取 url 参数
	 * @returns {___anonymous281_282}
	 */
	getUrlParm : function() {

		var locationurl = window.location.href;
		var tem0 = locationurl.split("#");
		var tem = tem0[0].split('?');
		var paramsdata = {};

		if (tem.length > 1) {

			var parms = tem[1].split('&');

			for (var i = 0; i < parms.length; i++) {

				var param = parms[i].split('=');

				paramsdata[param[0]] = param[1];

			}
		}

		return paramsdata;

	}
	,
	/**
	 * 响应返回处理
	 * @param stauts
	 * @param action
	 * @param alertMessage
	 */
	alertAction : function(stauts, action, ext) {

		var code = stauts.split('.');

		var prefix = code[0];
			
		var suffix = code.length==1 ?'0' : code[1];

		var defaultAction = {
			success : function() {
				
				if(suffix=='0'){

					alertMessage.alert('操作成功','操作成功');
					
				}else if(suffix=='1'){
			
					alertMessage.alert('操作成功','查询成功');
					
				}else if(suffix=='2'){
					
					alertMessage.alert('操作成功','添加成功');
					
				}else if(suffix=='3'){
		
					alertMessage.alert('操作成功','更改成功');
					
				}else if(suffix=='4'){

					alertMessage.alert('操作成功','删除成功');
					
				}
				
				if(action!= undefined){
					
					action.success();
				}

			},
			validation : function() {
				if(suffix=='0'){
					alert("input error");
				}
				
                 if(action!= undefined){
					
					action.validation();
				}

			},
			exception : function() {
				if(suffix=='0'){
					alert("server error");
				}else if(suffix=='1'){
					alert("server application error");
				}else if(suffix=='2'){
					alert("server date error");
				}
				else if(suffix=='3'){
					alert("server timeout error");
				}
				
				   if(action!= undefined){
						
						action.exception();
					}
			},
			refused : function() {
				if(suffix=='0'){
					alert("server refused");
				}else if(suffix=='1'){
					alert("appliaction logic refused");
				}else if(suffix=='2'){
					alert("authority refused");
				}else if(suffix=='2'){
					alert("data refused");
				}
			
				if(action!= undefined){
					
					action.refused();
				}
			}
		};

		if (prefix == '1') {

			if (ext!=undefined &&ext.success != undefined) {

				ext.success(suffix);

			} else {

				defaultAction.success(suffix);

			}

		} else if (prefix == '2') {
			if (ext!=undefined &&ext.validation != undefined) {

				ext.validation(suffix);

			} else {

				defaultAction.validation(suffix);

			}

		} else if (prefix == '3') {
			if (ext!=undefined &&ext.exception != undefined) {

				ext.exception(suffix);

			} else {

				defaultAction.exception(suffix);

			}

		} else if (prefix == '4') {
			if (ext!=undefined &&ext.refused != undefined) {

				ext.refused(suffix);

			} else {

				defaultAction.refused(suffix);

			}

		}

	},
	/**
	 * 多文件上传控件触发
	 */
	initFileInput:function(){
		
	var file_inputs=$("input[type='file']");

	
	for(var i=0;i<file_inputs.length;i++){
    	if(!isNaN(i)){
    		
       var uploadUrl=	file_inputs[i].getAttribute("uploadUrl");
       var uploadAsync=file_inputs[i].getAttribute("uploadAsync");
       var allowedFile =file_inputs[i].getAttribute("allowedFile");
    	
       var maxFiles =file_inputs[i].getAttribute("maxFiles");
    	
       var success=	file_inputs[i].getAttribute("success");
      
       var fn =function(){} ;
       if(success){
    	   fn=window[success]; 
       }
       
    	var allowedFileExtensions = null;
    	
    	if(allowedFile){
     	allowedFileExtensions=allowedFile.split(",");
    	}
    	
    	
    	if(!(maxFiles)){
    	 maxFiles =1;
       	}
    	
    	/*{  uploadExtraData: data,
			maxFileCount: maxFiles,
		    allowedFileExtensions: allowedFileExtensions,
	    uploadAsync: uploadAsync,
	    uploadUrl: uploadUrl ,// server upload action
	    successcallback:fn
	    }*/
    		$(file_inputs[i]).fileinput(
    	   {  
    		   maxFileCount: maxFiles,
    		   uploadAsync: uploadAsync,
    		   uploadUrl: uploadUrl ,
    		   successcallback:fn,
    		   allowedFileExtensions: allowedFileExtensions}
    		);
    	};
    	}
	
	},
	/**
	 * 日期格式化
	 * @param fmt
	 * @param date
	 * @returns
	 */
	dateFormat :function(fmt,date)   
	{ //author: meizz   
	  var o = {   
	    "M+" : date.getMonth()+1,                 //月份   
	    "d+" : date.getDate(),                    //日   
	    "h+" : date.getHours(),                   //小时   
	    "m+" : date.getMinutes(),                 //分   
	    "s+" : date.getSeconds(),                 //秒   
	    "q+" : Math.floor((date.getMonth()+3)/3), //季度   
	    "S"  : date.getMilliseconds()             //毫秒   
	  };   
	  if(/(y+)/.test(fmt))   
	    fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));   
	  for(var k in o)   
	    if(new RegExp("("+ k +")").test(fmt))   
	  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
	  return fmt;   
	} ,
	
	paramEffec:function(param){
		
		alert(param);
		if(param){
			
			alert(param);
			return param;
		}else{
			return '';
		}
	
	},
	/**
	 *  自动获取  触发元素对象所在 tr 中 所有表单元素 name  value 封装为 数据对象
	 * @param element 触发元素对象
	 * @param depth  向上深度 默认为4
	 * @returns {___anonymous5243_5244}
	 */
	getCommitDataFromTr:function (element,depth){
		
		 var commitdata={};
		 
	     var tr=this.getOnEventTr(element,depth);
	
	 		var inputs = tr.find("input");
	 		var selects =   tr.find("select");
	 		var textareas =tr.find("textarea");
	 		  
	    for(var j=0;j<inputs.length;j++){
	 			
	 	 var name=inputs[j].getAttribute("name");
	 	 var value=inputs[j].value;
	 	 commitdata[name]=value;
	 	   }
	 		
	    for(var j=0;j<selects.length;j++){
	 			
	 	 var name=selects[j].getAttribute("name");
	    var option = $(selects[j]).find("option:selected");
	 	 var value=  option.val();
	 	 commitdata[name]=value;
	 	   }
	    
	    for(var j=0;j<textareas.length;j++){
				
		 var name=textareas[j].getAttribute("name");
		 var value=  $(textareas[j]).val();
		 commitdata[name]=value;	
		   }
	  
		return commitdata;
		
	},
	
	getOnEventTr:function(enevt,depth){
		if(depth){
		}else{
			depth=4;
		}
		
		var tr;
		
		 for(var i=0;i<depth;i++){
			 
				var parent=	$(enevt).parent();
			 	
			 	  if(parent.is('tr')){
			 		 tr=parent;
			 		 break;
			 	  }else{
			 		  
			 		 enevt=parent;
			 		  
			 	  }
		 }
		
		return tr;
	}

}